package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/01/13 22:01
 **/
public class Day1_13_Num2287 {
    class Solution {
        public int rearrangeCharacters(String s, String target) {
            int[] arr = new int[26];
            for(char c : s.toCharArray())
                arr[c-'a']++;
            int[] count = new int[26];
            for(char c : target.toCharArray())
                count[c-'a']++;
            int ans = Integer.MAX_VALUE;
            for(int i = 0;i < 26; ++i) {
                if(count[i] == 0) continue;
                ans = Math.min(ans, arr[i] / count[i]);
            }
            return ans;
        }
    }
}